package cn.com.headfree.drafts.exception;

import cn.com.headfree.base.controller.ResultData;
import cn.com.headfree.drafts.controller.DraftsController;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author bryin
 * @create 2021-03-24 14:06
 */
@RestControllerAdvice(basePackages = {"cn.com.headfree.drafts.controller"})
public class DraftControllerAdvice {
    private static final Logger LOG = LogManager.getLogger(DraftControllerAdvice.class);
    @ExceptionHandler(Exception.class)
    public ResultData exceptionHandler(Exception e){
        LOG.error(e);
        return ResultData.fail(e.getMessage());
    }
}
